﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.util.SuperPage" %>
<%@ page import="com.mtbu.bean.SysLog" %>
<%@ page import="my.myorm.tool.jdbc.SQLExecutor" %>
<%@ page import="my.myorm.tool.jdbc.ResultList" %>
<%@ page import="my.myorm.tool.jdbc.Pages" %>
<%@ page import="my.myorm.tool.jdbc.SQLManager" %>
<%@ page import="com.util.SuperString" %>
<%@ page import="com.mtbu.comm.Util" %>
<%@ page import="com.util.SuperDate" %>
<%@ page import="java.util.Calendar" %>
<%@page import="com.util.SuperFile"%>
<%@page import="com.util.SuperMath"%>
<%@page import="java.util.Date"%>
<%@page import="com.util.DESUtil"%>
<%@page import="com.mtbu.comm.Constant"%>
<%@page import="com.mtbu.bean.SysRole"%>
<%@page import="com.mtbu.bean.SysUser"%>
<%@include file="sys_commcheck.jsp"%>
<%
String curFile = SuperPage.getCurURLFile(request);
String modFile = SuperFile.getFileName(curFile) + "mod.jsp";
String modFileDo = SuperFile.getFileName(curFile) + "moddo.jsp";
String modFilePermission = "sys_rolepermission.jsp";
String modFileStepPermission = "sys_steppermission.jsp";
String curName = "系统用户";
String queryname = SuperString.notNullTrim(request.getParameter("s_queryname"));
queryname = queryname.replace("'","''");
SQLExecutor conn = SQLManager.getSQLExecutor();
int s_roleid = SuperString.getInt(request.getParameter("s_roleid"));
int s_pagesize=SuperString.getInt(request.getParameter("s_pagesize"));
String dropparam="s_roleid,s_pagesize,s_queryname";
if(request.getMethod().equalsIgnoreCase("post")){
    StringBuffer sbparam=new StringBuffer();
    if(s_roleid>0) sbparam.append("&s_roleid=").append(s_roleid);
    if(s_pagesize>0) sbparam.append("&s_pagesize=").append(s_pagesize);
    if(queryname.length()>0)sbparam.append("&s_queryname=" + Util.encodeUrl(queryname) );
    String strparam=sbparam.toString();
    if(strparam.startsWith("&")) strparam="?"+strparam.substring(1);
    strparam+="".equals(strparam)? SuperPage.getQueryQ(request,dropparam): SuperPage.getQueryAnd(request,dropparam);
	System.out.print("=======ff============" + curFile+strparam);
    response.sendRedirect(curFile+strparam);
    return;
}
String sql = "select a.*,b.rolename from sys_user as a " +
        "left join sys_role as b " +
        "on a.roleid=b.id " +
        "where 1=1 " +
        (Constant_isSuperAdmin ? "" : " and a.username<>'" +
                Constant_UserName + "' and a.username not like '%admin' ") +
        (s_roleid>0?(" and roleid="+s_roleid):"")+
        (queryname.length()>0?(" and a.username like '"+queryname + "%'"):"")+
        " order by b.id,a.username";
int pagesize=Util.getPageSizeOfCookie(request,response,s_pagesize);
Pages pages = new Pages(pagesize, "a.id", request);
ResultList list = conn.query(sql, false, pages);
sql = "select * from sys_role " +
	(Constant_isSuperAdmin ? "" : " where rolename not like '%管理员' ") +
	"order by id";
ResultList rolelist = conn.query(sql, false, null);
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><%=curName%></title>
<link href="css/adminPPLive.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="js/comm.js"></script>
<script language="javascript" src="js/tablecell.js"></script>
<script type="text/javascript" src="js/jquery.js" language="javascript"></script>
<script type="text/javascript" src="js/jquery.alerts.js" language="javascript"></script>
</head>
<body>
<div class="adminRight">
  <div class="adminBorderTop">
    <div class="adminBorderTopLeft"></div>
    <div class="adminBorderTopTitle">
      <div class="adminBorderTopTitleLeft"></div>
      <div class="adminBorderTopTitleMiddle"><%=curName%>维护</div>
      <div class="adminBorderTopTitleRight"></div>
    </div>
    <div class="adminBorderTopRight"></div>
  </div>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F7F8F9">
  <tr>
    <td class="adminBorderMiddleLeft"></td>
    <td>
    <div class="admTab">
      <ul>
      <li><a href="<%=curFile+"?s_roleid=0"%><%=SuperPage.getQueryAnd(request,"s_roleid")%>" <%if(s_roleid==0)out.println("class='admTabCut'");%>>全部</a></li>
      <%for(int i=0;i<rolelist.size();i++){
    	  SysRole role = rolelist.get(i).get(SysRole.class);
      %>
        <li><a href="<%=curFile+"?s_roleid="+role.getId()%><%=SuperPage.getQueryAnd(request,"s_roleid")%>" <%if(s_roleid==role.getId())out.println("class='admTabCut'");%>><%=role.getRoleName()%></a></li>
		<%}%>
      </ul>
    </div>
    </div>
<!--分页开始-->
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="60%" colspan="2" align="left" bgcolor="#e7f0f9"><div class="admPage"><%=SuperPage.generatePageNavSingleNew(list.getAllCount(), request, null, pages.getPageSize(),"个")%></div></td>
     <form name="form_s" action="<%=curFile%><%=SuperPage.getQueryQ(request,dropparam)%>" method="post" class="formline">
    <td width="30%" align="right" bgcolor="#e7f0f9">
    	用户名：<input  class="admTextFirst" type="text" name="s_queryname" value="<%= queryname %>"></input>
	 <input name="Submit2" type="submit" value="" style="background-image:url(images/adminSearchBtn.png);width: 59;height: 22;border:0px;cursor:pointer;">
    </td>
    <td width="30%" align="right" bgcolor="#e7f0f9">
    <div class="admHouseBtn"><li><a href="<%=modFile%><%=SuperPage.getQueryQ(request,"act,id")%>">增加<%=curName%></a></li></div>
    </td>
    </form>
  </tr>
</table>
<!--分页结束-->
<table id="table_data" width="100%" border="0" cellpadding="1" cellspacing="1" class="table_bord">
  <tr class="table_bord_ttl">
    <td>系统用户名称</td>
    <td>所属角色</td>
    <td>操作</td>
  </tr>
<%
    for(int i = 0; i < list.size(); i++) {
        SysUser user=list.get(i).get(SysUser.class);
        SysRole role=list.get(i).get(SysRole.class);

        String trclass = i % 2 == 0 ? "tr_class1" : "tr_class2";
%>
  <tr height="20" class="<%=trclass%>" onMouseMove="cell_over(this);" onMouseOut="cell_out(this)" onClick="cell_click(this);">
    <td><%=user.getUserName()%></td>
    <td><%=role.getRoleName()%></td>
    <td>
	<a href="<%=modFilePermission%>?from=user&id=<%=user.getId()%>">权限设置</a>
	| <a href="<%=modFileStepPermission%>?from=user&id=<%=user.getId()%>">流程权限设置</a>
	| <a href="<%=modFile%>?act=mod&id=<%=user.getId()%><%=SuperPage.getQueryAnd(request,"act,id")%>">修改</a>
	| <a href="<%=modFileDo%>?act=del&id=<%=user.getId()%><%=SuperPage.getQueryAnd(request,"act,id")%>" onClick="return delconfirm();">删除</a>
	</td>
  </tr>
<%
    }
    if(list.size()==0){
%>
  <tr class="tr_class1">
    <td height="50" colspan="4" align="center">没有数据</td>
  </tr>
<%
    }
%>
</table>
<!--分页开始-->
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr valign="middle">
    <td width="100%" align="left" bgcolor="#e7f0f9"><div class="admPage"><%=SuperPage.generatePageNavSingleNew(list.getAllCount(), request, null, pages.getPageSize(),"个")%></div></td>
  </tr>
</table>
   </td>
    <td class="adminBorderMiddleRight"></td>
  </tr>
</table>
<div class="adminBorderBottom">
  <div class="adminBorderBottomLeft"></div>
  <div class="adminBorderBottomRight"></div>
</div>
</div>
<%@include file="sys_commfooter.jsp"%>
</body>
</html>